<?php
namespace Home\Controller;
use Think\Controller;
class MessageController extends Controller {
    public function liuyan(){
		$com=D('Comments');
           if(IS_POST){    
            $data['name']=I('name');
    		$data['content']=I('content');
    		$data['com_time']=time();
    		$data['style']=I('style');	
           //验证码验证
             $code = I('post.yzm');
            $Verify = new \Think\Verify();
             if(!$Verify->check($code)){
                 $this->error('验证码错误','',2);
             }

            
        if(!$com->create($data)){
                echo $com->getError();
                exit;
            }else
            {	
                if($com->add())
                {
                    //$this->success('新增成功！',U('/admin/news/news',3));
                	 echo "新增成功";
                }else
                {
                    $this->error('新增失败！');
                }
            }
}

        $news=D("news");
       
        $lists=$news->order('xid desc')->limit(0,5)->select();
        //var_dump($list);
        $count = $com->count();
        $Page       = new \Think\Page($count,2);//继承
        $show       = $Page->show();//展示
        $list = $com->limit($Page->firstRow.','.$Page->listRows)->select();
       
        $this->assign('count',$count);
        $this->assign('page',$show);
        $this->assign('coms',$list);
        $this->assign('lists',$lists);

	
		$this->display();
	}


	public function news(){
		$news=D("news");
		
		$lists=$news->order('xid desc')->limit(0,5)->select();
    	//var_dump($list);
    	$count = $news->count();
        $Page       = new \Think\Page($count,2);//继承
        $show       = $Page->show();//展示
        $list = $news->limit($Page->firstRow.','.$Page->listRows)->select();
       
        $this->assign('count',$count);
        $this->assign('page',$show);
        $this->assign('list',$list);
        $this->assign('lists',$lists);
        






    	$this->display();  

	}
	public function newslist(){
		$news=D("news");

		$list=$news->find(I('xid'));
		
		$lists=$news->order('xid desc')->limit(0,5)->select();
    	
    	$this->assign('list',$list);
    	//var_dump($list);
        $this->assign('lists',$lists);
        
    	$this->display();  

}

 public function yzm(){
 
        $Verify = new \Think\Verify();
        $Verify->fontSize = 20;
        $Verify->length = 4;
        $Verify->useNoise = false;
        $Verify->entry();
    }
}